/*
 * Copyright (C) 2025, KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Authors: iaom <zhangpengfei@kylinos.cn>
 *
 */
import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.ukui.quick.widgets 1.0
import org.ukui.quick.items 1.0
import org.ukui.okButton 1.0

WidgetItem {
    id: rootWidget
    Layout.fillWidth: false
    Layout.fillHeight: true
    Layout.preferredWidth: (height - 8) * 2600/677
    Layout.preferredHeight: parent.height
    clip: false

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true
        anchors {
            leftMargin: 0
            topMargin:  4
            rightMargin: 0
            bottomMargin: 4
        }
        StyleBackground {
            anchors.fill: parent
            radius: Theme.normalRadius
            useStyleTransparency: false
            paletteRole: Theme.WindowText
            alpha: parent.containsPress ? 0.16 : parent.containsMouse ? 0.08 : 0
            Tooltip {
                id: tooltip
                anchors.fill: parent
                mainText: Widget.tooltip
                posFollowCursor: false
                location: {
                    switch (Widget.container.position) {
                        case Types.Bottom:
                            return Dialog.BottomEdge;
                        case Types.Left:
                            return Dialog.LeftEdge;
                        case Types.Top:
                            return Dialog.TopEdge;
                        case Types.Right:
                            return Dialog.RightEdge;
                    }
                }
                margin: 6
            }
        }
        Image {
            id: backgroundImg
            anchors.fill: parent
            fillMode: Image.Stretch
            source: "qrc:///res/openkylin.png"
            smooth: true
        }
        onClicked: {
            okButton.launch();
        }
        OkButton {
            id: okButton
        }
    }
}
